package routers

import (
	"cgs-server/server"
	appRouter "cgs-server/server/cgs/app/router"
	noticeRouter "cgs-server/server/cgs/notice/router"
	"cgs-server/server/routers/api"
	"cgs-server/server/routers/api/bim"
	"cgs-server/server/routers/api/sms"
	"cgs-server/server/routers/api/workflow"
	"cgs-server/server/store/mongo"
)

func Init() {

	appRouter.Init()
	noticeRouter.Init()
	storeIns, _ := mongo.GetMongoFactory()

	// bim resource
	{
		bimHandler := bim.NewBimHandler(storeIns)
		server.Post("/api/bim/uploadFileToOss", bimHandler.UploadFileToOss, "bim_上传文件到oss", server.None)
		server.Post("/api/bim/file/upload", bimHandler.UploadFile, "bim_上传文件", server.Login)       // todo 修改权限为登录
		server.Post("/api/bim/file/translate", bimHandler.TranslateFile, "bim_转换文件", server.Login) // todo 修改权限为登录
		server.Get("/api/bim/callback", bimHandler.Callback, "bim_回调函数", server.Login)             // todo 修改权限为登录
		server.Get("/api/bim/file/list", bimHandler.ListFile, "bim_模型列表", server.Login)            // todo 修改权限为登录
		server.Post("/api/bim/file/delete", bimHandler.DeleteFile, "bim_删除模型", server.Login)       // todo 修改权限为登录
		server.Get("/api/bim/file/view-token", bimHandler.ViewToken, "bim_模型token", server.None)
		server.Get("/api/bim/file/support-type", bimHandler.GetSupportType, "bim_支持模型类型", server.None)
		server.Get("/api/bim/file/info", bimHandler.FileInfo, "bim_模型信息", server.None)
	}

	// sms resource
	{
		smsHandler := sms.NewSmsHandler()
		server.Post("/api/getValidationCode", smsHandler.GetValidationCode, "获取短信验证码", server.None)
		server.Post("/api/checkValidationCode", smsHandler.CheckValidationCode, "校验短信验证码", server.None)
	}

	// version resource
	{
		versionHandler := api.NewVersionHandler()
		server.Get("/api/version", versionHandler.GetVersion, "获取版本信息", server.None)
	}

	// workflow
	{
		workflowHandler := workflow.NewWorkflowHandler(storeIns)
		server.Post("/api/workflow/save", workflowHandler.Save, "新增工作流", server.Login)
		server.Post("/api/workflow/update", workflowHandler.Update, "更新工作流", server.Login)
		server.Post("/api/workflow/delete", workflowHandler.Delete, "删除工作流", server.Login)
		server.Get("/api/workflow/list", workflowHandler.List, "获取工作流列表", server.Login)
		server.Get("/api/workflow/get", workflowHandler.Get, "获取工作流详情", server.Login)
	}

	{
		uploadHandler := api.NewUploadHandler(storeIns)
		server.Post("/api/upload-file", uploadHandler.Upload, "上传文件", server.Login)
	}
}
